package fatworm.concept;

import fatworm.util.Lib;

/**
 * 	aggregation function 
 */
public class AggFunc {
	private int func;
	private AggFunc( int func ){
		this.func = func; 
 	}
	/**
	 * @return the integer representation of function
	 */
	public int getFunc(){
		return func;
	}
	
	public String toString(){
		return toString( func );
	}
	
	/**
	 * get the string representation of function
	 * @param func	integer representation
	 * @return	string representation
	 */
	public static String toString( int func ){
		switch( func ){
			case F_AVG 	: return "AVG";
			case F_COUNT: return "COUNT";
			case F_MIN	: return "MIN";
			case F_MAX	: return "MAX";
			case F_SUM	: return "SUM";
			default		: Lib.assertNotReached(); return null;
		}
	}
	public static final int F_AVG = 0 , F_COUNT = 1 , F_MIN = 2,  F_MAX = 3, F_SUM = 4; 
	public static final int NUM_FUNCTIONS = 5;
	public static final AggFunc AVG 	= new AggFunc( F_AVG );
	public static final AggFunc	COUNT 	= new AggFunc( F_COUNT );	
	public static final AggFunc	MIN 	= new AggFunc( F_MIN );
	public static final AggFunc	MAX 	= new AggFunc( F_MAX );
	public static final AggFunc	SUM 	= new AggFunc( F_SUM );	
}
